package com.happy3w.cmds.config;

import com.happy3w.bean.DefaultTypeDetector;
import com.happy3w.bean.factory.ConfigBeanHelper;
import com.happy3w.bean.factory.DecodeHelper;
import com.happy3w.bean.factory.TypeDetector;
import com.happy3w.bean.json.JsonHelper;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BeanConfigs {

    @Bean
    public DecodeHelper decodeHelper() {
        return new JsonHelper();
    }

    @Bean
    public TypeDetector typeDetector() {
        return new DefaultTypeDetector();
    }

    @Bean
    public ConfigBeanHelper configBeanHelper(DecodeHelper decodeHelper, TypeDetector typeDetector, ApplicationContext applicationContext) {
        return new ConfigBeanHelper(decodeHelper, typeDetector, applicationContext::getBean);
    }

}
